package com.future.springcloud.config;

import org.springframework.cloud.gateway.route.RouteLocator;
import org.springframework.cloud.gateway.route.builder.RouteLocatorBuilder;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * 硬编码网关配置
 */
@Configuration
public class GatewayConfig {

    @Bean
    public RouteLocator customRouteLocator(RouteLocatorBuilder routeLocatorBuilder) {
        RouteLocatorBuilder.Builder routes = routeLocatorBuilder.routes();
        //通过 localhost:9527/guonei -> http://news.baidu.com/guonei
        routes.route("path_route_future",r -> r.path("/guonei")
                .uri("http://news.baidu.com/guonei"))
                .build();

        return routes.build();
    }


}
